package com.zzg.datastructure.recursion;

/**
 * @Author zhengzg
 * @Date 2022-08-19
 * @Version v1.0
 */
public class RecursionTest {
    public static void main(String[] args) {
        test(4);
        System.out.println("5的阶乘：" + mul(5));
    }

    // 打印问题
    public static void test(int n){
        if (n > 2){
            test(n - 1);
        }
        System.out.println("n="+n);
    }

    // 阶乘问题
    public static int mul(int num){
        if (num == 1){
            return 1;
        } else {
          return mul(num -1) * num;
        }
    }
}
